<form id="import-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Cate_id')}:</label>
        <div class="col-xs-12 col-sm-8">
            <!--<input id="c-cate_id" data-rule="required" data-source="exam/cate/selectpage" data-params='{"custom[kind]":"QUESTION"}' class="form-control selectpage" name="row[cate_id]" type="text" value="">-->
            <div>
                <select name="" id="sel1" style="width: 20rem;height: 3rem;">
                    <option value="">--请选择--</option>
                    {volist name="clist" id="vo"}
                    <option value="{$vo.id}" {if $vo.id eq $categoryList.parent_id1 }selected{/if}>{$vo.name}</option>
                    {/volist}
                </select>
            </div>
            <div style="margin-top: 1rem;">
                <select name="" id="sel2" style="width: 20rem;height: 3rem;">
                    <option value="">--请选择--</option>
                    {volist name="categoryList.parent_list2" id="vo2"}
                    <option value="{$vo2.id}" {if $vo2.id eq $categoryList.parent_id2 }selected{/if}>{$vo2.name}</option>
                    {/volist}
                </select>
            </div>
            <div style="margin-top: 1rem;">
                <select name="row[cate_id]" id="c-cate_id" style="width: 20rem;height: 3rem;">
                    <option value="">--请选择--</option>
                    {volist name="categoryList.parent_list3" id="vo3"}
                    <option value="{$vo3.id}" {if $vo3.id eq $categoryList.parent_id3 }selected{/if}>{$vo3.name}</option>
                    {/volist}
                </select>
            </div>

        </div>
    </div>

    <!--<div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Exam_type_id')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-exam_type_id" data-rule="required" data-source="exam_type/index" class="form-control selectpage" name="row[exam_type_id]" type="text" value="">
        </div>
    </div>-->

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">选择文件:</label>
        <div class="col-xs-12 col-sm-8">
            <a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('exam/question/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>
            <input type="hidden" id="file_url">
            <label id="question_count" class="m-l-10"></label>
            <!--<input id="test" type="button" value="test">-->
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">模板文件:</label>
        <div class="col-xs-12 col-sm-8">
            <a href="/assets/addons/exam/template/import_template.xlsx" target="_blank" class="btn btn-success" title="点击下载模板文件"><i class="fa fa-download"></i> 点击下载模板文件</a>
        </div>
    </div>

    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
        </div>
    </div>
</form>
<script src="__CDN__/assets/libs/jquery/dist/jquery.min.js"></script>
<script>
    var valid_result = true;
    $('#sel1').change(function () {
        var cid = $(this).val();
        var hhtml = `<option value="">--请选择--</option>`;
        $('#sel2').html(hhtml);
        $.ajax({
            url:"exam/question/get_qcate",
            method: 'post',
            data: { 'cid': cid },
            success:function(data) {
                // console.log(data);
                if(data.code == 100)
                {

                    var html = '';
                    var list = data.data.list;
                    console.log(list);
                    for (var j = 0; j < list.length; j++)
                    {
                        html += `<option value="` + list[j].id + `">` + list[j].name + `</option>`;
                    }

                    $('#sel2').append(html);

                }
            },
            error: function(err) {
                console.log("失败了: " + err);
            }
        });
    });
    $('#sel2').change(function () {
        var cid = $(this).val();
        var hhtml = `<option value="">--请选择--</option>`;
        $('#c-cate_id').html(hhtml);
        $.ajax({
            url:"exam/question/get_qcate",
            method: 'post',
            data: { 'cid': cid },
            success:function(data) {
                // console.log(data);
                if(data.code == 100)
                {

                    var html = '';
                    var list = data.data.list;
                    console.log(list);
                    for (var j = 0; j < list.length; j++)
                    {
                        html += `<option value="` + list[j].id + `">` + list[j].name + `</option>`;
                    }

                    $('#c-cate_id').append(html);

                }
            },
            error: function(err) {
                console.log("失败了: " + err);
            }
        });
    });
</script>
